/**
 * Copyright 2008 ts Inc.
 */
package net.wicp.tams.common.agent;

import java.lang.reflect.Method;
import java.util.concurrent.Callable;

import net.bytebuddy.implementation.bind.annotation.AllArguments;
import net.bytebuddy.implementation.bind.annotation.Origin;
import net.bytebuddy.implementation.bind.annotation.RuntimeType;
import net.bytebuddy.implementation.bind.annotation.SuperCall;
import net.bytebuddy.implementation.bind.annotation.This;
/***
 * aaaa.
 * @author Administrator
 *
 */
public class TimeInterceptor {
	@RuntimeType
	public static Object intercept(@This Object obj, @AllArguments Object[] allArguments,@Origin Method method, @SuperCall Callable<?> callable) throws Exception {
		long start = System.currentTimeMillis();
		try {
			// 原有函数执行
			return callable.call();
		} finally {
			System.out.println(method + ": took " + (System.currentTimeMillis() - start) + "ms");
		}
	}
}
